package org.company.mars.kafka;

import java.util.Properties;

import org.junit.Test;

import kafka.javaapi.producer.Producer;
import kafka.producer.KeyedMessage;
import kafka.producer.ProducerConfig;

public class ProducerDemo {
	
	@Test
	public void simpleProduce() {
		Properties props = new Properties();
		props.put("metadata.broker.list", "10.86.44.167:9092");
		props.put("serializer.class", "kafka.serializer.StringEncoder");
		props.put("key.serializer.class", "kafka.serializer.StringEncoder");
		props.put("request.required.acks", "1");
		//props.put("partitioner.class", "com.catt.kafka.demo.PartitionerDemo");
		
		ProducerConfig config = new ProducerConfig(props);
		Producer<String, String> producer = new Producer<String, String>(config);
		for(long i = 0 ; i < 100; i++) {
			KeyedMessage<String, String> data = new KeyedMessage<String, String>("test1", "abc");
			producer.send(data);
		}
	}
	
}
